package com.newbingo.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.AssociationOverride;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.CollectionOfElements;

@Entity
public class Agent extends User{	
	
	private Agent parentAgent;
	private Set<Agent> childAgent;
	private Set<Member> members;
	private Set<BetSetting> settings;
	//0表示是代理,1表示是股东
	private Integer agentType;
	//占成比
	private Integer divinationRate;
	//退水率
	private Integer profitRate;

	
	@CollectionOfElements
	public Set<BetSetting> getSettings() {
		return settings;
	}
	public void setSettings(Set<BetSetting> settings) {
		this.settings = settings;
	}
	@ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, targetEntity = Agent.class)
	@JoinColumn(name = "parent_id")
	public Agent getParentAgent() {
		return parentAgent;
	}

	public void setParentAgent(Agent parentAgent) { 
		this.parentAgent = parentAgent;
	}

	@OneToMany(mappedBy = "parentAgent", cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Agent.class)
	public Set<Agent> getChildAgent() {
		return childAgent;
	}

	public void setChildAgent(Set<Agent> childAgent) {
		this.childAgent = childAgent;
	}

	public Agent() {
		super();
	}

	@OneToMany(mappedBy="agent",cascade=CascadeType.ALL,fetch=FetchType.LAZY,targetEntity=Member.class)
	public Set<Member> getMembers() {
		return members;
	}
	public void setMembers(Set<Member> members) {
		this.members = members;
	}
	
	public Integer getAgentType() {
		return agentType;
	}
	public void setAgentType(Integer agentType) {
		this.agentType = agentType;
	}

	
	public Integer getDivinationRate() {
		return divinationRate;
	}
	public void setDivinationRate(Integer divinationRate) {
		this.divinationRate = divinationRate;
	}
	
	public Integer getProfitRate() {
		return profitRate;
	}
	public void setProfitRate(Integer profitRate) {
		this.profitRate = profitRate;
	}
	


	

}
